<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Getting Started With Zend_Markup - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.markup.getting-started.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.markup.getting-started.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.markup.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.markup.html">Zend_Markup</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.markup.parsers.html">Zend_Markup Parsers</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.markup.getting-started" class="section"><div class="info"><h1 class="title">Getting Started With Zend_Markup</h1></div>
    

    <p class="para">
        This guide to get you started with <span class="classname">Zend_Markup</span> uses the BBCode parser
        and <acronym class="acronym">HTML</acronym> renderer. The priciples discussed can be adapted to other
        parsers and renderers.
    </p>

    <div class="example" id="zend.markup.getting-started.basic-usage"><div class="info"><p><b>Example #1 Basic Zend_Markup Usage</b></p></div>
        

        <div class="example-contents"><p>
            We will first instantiate a <span class="classname">Zend_Markup_Renderer_Html</span> object
            using the  <span class="methodname">Zend_Markup::factory()</span> method. This will also create
            a <span class="classname">Zend_Markup_Parser_Bbcode</span> object which will be added to the
            renderer object.
        </p></div>

        <div class="example-contents"><p>
            Afther that, we will use the  <span class="methodname">render()</span> method to convert a piece
            of BBCode to <acronym class="acronym">HTML</acronym>.
        </p></div>

        <pre class="programlisting brush: php">
// Creates instance of Zend_Markup_Renderer_Html,
// with Zend_Markup_Parser_BbCode as its parser
$bbcode = Zend_Markup::factory(&#039;Bbcode&#039;);

echo $bbcode-&gt;render(&#039;[b]bold text[/b] and [i]cursive text[/i]&#039;);
// Outputs: &#039;&lt;strong&gt;bold text&lt;/strong&gt; and &lt;em&gt;cursive text&lt;/em&gt;&#039;
</pre>

    </div>

    <div class="example" id="zend.markup.getting-started.complicated-example"><div class="info"><p><b>Example #2 A more complicated example of Zend_Markup</b></p></div>
        

        <div class="example-contents"><p>
            This time, we will do exactly the same as above, but with more complicated BBCode
            markup.
        </p></div>

        <pre class="programlisting brush: php">
$bbcode = Zend_Markup::factory(&#039;Bbcode&#039;);

$input = &lt;&lt;&lt;EOT
[list]
[*]Zend Framework
[*]Foobar
[/list]
EOT;

echo $bbcode-&gt;render($input);
/*
Should output something like:
&lt;ul&gt;
&lt;li&gt;Zend Framework&lt;/li&gt;
&lt;li&gt;Foobar&lt;/li&gt;
&lt;/ul&gt;
*/
</pre>

    </div>

    <div class="example" id="zend.markup.getting-started.incorrect-input"><div class="info"><p><b>Example #3 Processing incorrect input</b></p></div>
        

        <div class="example-contents"><p>
            Besides simply parsing and rendering markup such as BBCode,
            <span class="classname">Zend_Markup</span> is also able to handle incorrect input. Most BBCode
            processors are not able to render all input to <acronym class="acronym">XHTML</acronym> valid output.
            <span class="classname">Zend_Markup</span> corrects input that is nested incorrectly, and also
            closes tags that were not closed:
        </p></div>

        <pre class="programlisting brush: php">
$bbcode = Zend_Markup::factory(&#039;Bbcode&#039;);

echo $bbcode-&gt;render(&#039;some [i]wrong [b]sample [/i] text&#039;);
// Note that the &#039;[b]&#039; tag is never closed, and is also incorrectly
// nested; regardless, Zend_Markup renders it correctly as:
// some &lt;em&gt;wrong &lt;strong&gt;sample &lt;/strong&gt;&lt;/em&gt;&lt;strong&gt; text&lt;/strong&gt;
</pre>

    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.markup.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.markup.html">Zend_Markup</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.markup.parsers.html">Zend_Markup Parsers</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.markup.html">Zend_Markup</a></li>
  <li><a href="zend.markup.introduction.html">Introduction</a></li>
  <li class="active"><a href="zend.markup.getting-started.html">Getting Started With Zend_Markup</a></li>
  <li><a href="zend.markup.parsers.html">Zend_Markup Parsers</a></li>
  <li><a href="zend.markup.renderers.html">Zend_Markup Renderers</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>